from functools import reduce

lst1 = ['a', '1', '2bb', '234', '', '9']
def func1(s, ssr):
    tmp_s = s
    if not s.isdigit():
        tmp_s = ''
        for c in s:
            if c.isdigit():
                tmp_s += c
    tmp_ssr = ''
    for c in ssr:
        if c.isdigit():
            tmp_ssr += c
    return tmp_s+tmp_ssr
print(reduce(func1, lst1))



lst2 = [7,-8, 5, 4, 0, -2, -5]
lst21 = list(filter(lambda x:x>=0, lst2))
lst22 = list(filter(lambda x:x<0, lst2))
print(sorted(lst21)+sorted(lst22, key=abs))




s='asd234GDSdsf23'
s_lower = list(filter(lambda x:97<=ord(x)<=122, s))
s_lower
s_upper = list(filter(lambda x:x.isupper(), s))
s_jishu = list(filter(lambda x:x.isdigit() and int(x)%2, s))
s_oushu = list(filter(lambda x:x.isdigit() and not int(x)%2, s))
result = sorted(s_lower) + sorted(s_upper) + sorted(s_jishu) + sorted(s_oushu)
print(''.join(result))





